package com.automation.ljf.repository.impl.mapper;

import com.automation.ljf.domain.po.CaseStepReportPO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 操作mf_step_report表（存放用例步骤执行结果）
 *
 * @author lijiefeng
 * @since 2021/8/27
 */
@Mapper
public interface StepReportMapper {

    /**
     * 插入已执行的步骤结果
     * @param caseStepReportPOS     用例步骤执行结果镜像PO集合
     * @return  Integer
     */
    @Insert({"<script>" +
            "insert into mf_step_report" +
            "(id, report_id, step_id, step_name, step_xpath, step_operation, step_relation, step_amount, step_parameter, is_input, step_jsonpath, " +
            "expect_result, actual_result,step_window, step_res_detail, case_id, create_time, update_time) " +
            "values " +
            "<foreach item='stepReport' collection='list' index='index' open='' close='' separator=','>" +
            "(#{stepReport.id}, #{stepReport.reportId}, #{stepReport.stepId}, #{stepReport.stepName}, #{stepReport.stepXpath}, #{stepReport.stepOperation}, #{stepReport.stepRelation}," +
            "#{stepReport.stepAmount}, #{stepReport.stepParameter}, #{stepReport.isInput}, #{stepReport.stepJsonpath}, #{stepReport.expectResult}, " +
            "#{stepReport.actualResult},#{stepReport.stepWindow}, #{stepReport.stepResDetail}, #{stepReport.caseId}, #{stepReport.createTime}, #{stepReport.updateTime})" +
            "</foreach>" +
            "</script>"})
    Integer insertCaseStepReport(@Param("list") List<CaseStepReportPO> caseStepReportPOS);


    @Select("select id, report_id, step_id, step_name, step_xpath, step_operation, step_relation, step_amount, step_parameter, is_input, step_jsonpath, " +
            "expect_result, actual_result, step_window, step_res_detail, case_id, create_time, update_time " +
            "from mf_step_report " +
            "where report_id = #{rId} and is_delete = false ")
    List<CaseStepReportPO> selectStepReportByCaseReportId(@Param("rId") String reportId);

}
